﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BusinessLogicLayer;
using System.Resources;
using BusinessObjectLayer;
using ComplexDataType;
using System.Reflection;
using BusinessLogicLibrary;

namespace UserInterface
{
    public partial class SentenceUI : Form
    {
        private ResourceManager _ResourceManager = new ResourceManager("UserInterface.Properties.Resources", Assembly.GetExecutingAssembly());
        ExceptionHandlerBOL _ExceptionHandlerBOL;

        public SentenceUI()
        {
            InitializeComponent();
            SetContext();
        }
        private void SetContext()
        {
          FileBOL fileBOL = new FileBOL(ServerBLL.GetStringValue("SentencePath"));
          contextTextBox.Text = new FileBLL().ReadText(fileBOL);
        }
        private void setFarsiKeyboard_Enter(object sender, EventArgs e)
        {
            try
            {
                KeyboardControler.SetFarsiKeyboard();
            }
            catch (Exception exception)
            {
                _ExceptionHandlerBOL = ExceptionHandlerBLL.HandleException(exception);
                noticeLabel.ForeColor = Color.Red;
                noticeLabel.Text = _ExceptionHandlerBOL.Title;
            }
        }
        private void cancelButton_Click(object sender, EventArgs e)
        {
            CloseForm();
        }
        private void CloseForm()
        {
            this.Close();
        }

        private void editButton_Click(object sender, EventArgs e)
        {
            FileBOL fileBOL = new FileBOL(ServerBLL.GetStringValue("SentencePath"), contextTextBox.Text);
            new FileBLL().WriteText(fileBOL);
        }
    }
}
